<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <span>
            父组件中的msg值
            <input type="text" v-model="msg">
        </span>
        <comp :parentmsg="msg"></comp>
    </div>

    <template id="comp_template">
        <div>
            <p>子组件接收来自父级的元素：</p>
            <p>{{ parentmsg }}</p>
        </div>
    </template>
    <script>
        new Vue({
            el: "#app",
            data: {
                msg: ""
            },
            components: {
                comp: {
                    template: "#comp_template",
                    props: ["parentmsg"],
                    data() {
                        return {
                            parentmsg: this.parentmsg
                        }
                    }
                }                
            }
        })
    </script>
</body>
</html>